﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Elentok.Common.Async
{
  /// <summary>
  /// Contains extension methods for the <see cref="IAsyncTask"/> interface.
  /// </summary>
  public static class AsyncTaskExtensions
  {
    /// <summary>
    /// Determines whether the specified task is working (running or pending cancellation).
    /// </summary>
    /// <param name="task">The task.</param>
    /// <returns>
    /// 	<c>true</c> if the specified task is working; otherwise, <c>false</c>.
    /// </returns>
    public static bool IsWorking(this IAsyncTask task)
    {
      return task.State == AsyncTaskState.Running ||
        task.State == AsyncTaskState.PendingCancellation;
    }
  }
}
